1.code
import React from 'react';
import styles from './ImageFlicker.module.css';
import Image from "next/image";
function ImageFlicker() {
return (
<div className={styles.container}>
<div className={`${styles.flicker} ${styles.myImage}`}>
<Image src="/S__2990088_0.jpg" width={150} height={150} alt="Flickering Image" />
</div>
</div>
);
}
export default ImageFlicker;
.container {
display: flex;
justify-content: center;
align-items: center;
height: 200px;
}
.flicker {
animation: flicker 1s infinite;
}
@keyframes flicker {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0;
}
}
.myImage {
width: 100%;
height: auto;
display: block;
}
2.實作